/* Simple Stepper Motor Control Exaple Code * * by Dejan Nedelkovski, www.HowToMechatronics.com * * modified by Yasir Shafiullah on 01.05.2019 */ // defines pins numbers const int stepPin = 4; const int dirPin = 3; void setup() { // Sets the two pins as Outputs pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); } void loop() { digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction // Makes 200 pulses for making one full cycle rotation for(int x = 0; x < 200; x++) { digitalWrite(stepPin,HIGH); delay(500); // ms (Note : 1000ms = 1sec) digitalWrite(stepPin,LOW); delay(500); // ms (Note : 1000ms = 1sec) } }